/*
 * Copyright (c) 2023, Cshoo affiliates. All rights reserved.
 */

package org.cshoo.sf.price;

import org.cshoo.sf.entity.PurchaseItem;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author 杨翼
 * @version 1.0
 * @since 1.0
 */
public class ReductionStrategy extends DiscountStrategy {

    @Override
    public BigDecimal calcTotalPrice(List<PurchaseItem> purchaseItems) {
        BigDecimal superTotalPrice = super.calcTotalPrice(purchaseItems);
        if (superTotalPrice.compareTo(new BigDecimal(100)) >= 0) {
            return superTotalPrice.subtract(new BigDecimal(10));
        } else {
            return superTotalPrice;
        }
    }

}
